<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>具体出生时刻</title>
</head>
<body>
<?php
$d=mktime(17, 12, 0, 12, 04, 2001);
echo "出生日期是： " . date("Y-m-d H:m", $d) .'<br/>';
// 当前时刻的年龄
$d3=date_create('2001-12-04 17:12');
$d2=date_create(date('Y-m-d H:m'));
$diff=date_diff($d3,$d2);
echo $diff->format("当前年龄为%y 岁<br/>");
?>
<!-- 以秒计（利用JavaScript） -->
<script>
    var new_date=new Date();
    var old_date=new Date("2001-2-18 17:12:45");
    var difftime=(new_date-old_date)/1000;
    document.write("你已出生:"+difftime+"秒"+'<br/>');

    //以天计
    var days=parseInt(difftime/60/60/24);
    document.write("你已出生:"+days+"天"+'<br/>');

    //以年.月.日--小时h--分m'--秒s"计
    var years=parseInt(difftime/60/60/24/365);
    var month=parseInt(difftime/60/60/24%365%30/12+1);
    var dayss=parseInt(difftime/(60*60*24)/365);
    var hours=parseInt(difftime/3600)-24*days;
    var minutes=parseInt(difftime%3600/60);
    var seconds=parseInt(difftime%60);
    document.write("你已出生："+years+"年"+month+"个月"+dayss+"天"+hours+"个小时"+minutes+"分"+seconds+"秒");


</script>

</body>
</html>